//
//  TimelineDetailsTopView.m
//  aMoment
//
//  Created by dllo on 15/10/12.
//  Copyright © 2015年 LuckyHan. All rights reserved.
//

#import "TimelineDetailsTopView.h"
#import "AllHeaderFiles.h"

@implementation TimelineDetailsTopView

- (void)dealloc
{
    [_userImageView release];
    [_usernameLabel release];
    [_addTimeLabel release];
    [_lineLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _userImageView = [[UIImageView alloc] init];
//        _userImageView.backgroundColor = [UIColor grayColor];
        _userImageView.contentMode = UIViewContentModeScaleAspectFill;
        _userImageView.clipsToBounds = YES;
        [self addSubview:_userImageView];
        [_userImageView release];
        
        _usernameLabel = [[UILabel alloc] init];
//        _usernameLabel.backgroundColor = [UIColor grayColor];
        _usernameLabel.font = [UIFont systemFontOfSize:FONTSIZE_MIDDLE];
        [self addSubview:_usernameLabel];
        [_usernameLabel release];
        
        _addTimeLabel = [[UILabel alloc] init];
//        _addTimeLabel.backgroundColor = [UIColor grayColor];
        _addTimeLabel.font = [UIFont systemFontOfSize:FONTSIZE_SMALL];
        _addTimeLabel.textAlignment = NSTextAlignmentRight;
        _addTimeLabel.textColor = FONTCOLOR_GRAY;
        [self addSubview:_addTimeLabel];
        [_addTimeLabel release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _userImageView.frame = CGRectMake(20 * FIT_WIDTH, 15 * FIT_HEIGHT, 45 * FIT_WIDTH, 45 * FIT_WIDTH);
    _userImageView.layer.cornerRadius = _userImageView.Width / 2;
    
    _addTimeLabel.frame = CGRectMake(SCREEN_WIDTH - _userImageView.X - 150 * FIT_WIDTH, _userImageView.Y + _userImageView.Height / 2 - 10 * FIT_HEIGHT, 150 * FIT_WIDTH, 20 * FIT_HEIGHT);
    _usernameLabel.frame = CGRectMake(_userImageView.X + _userImageView.Width + 5 * FIT_WIDTH, _addTimeLabel.Y, SCREEN_WIDTH - _userImageView.X * 2 - _userImageView.Width - 15 * FIT_WIDTH - _addTimeLabel.Width, _addTimeLabel.Height);
    
    _lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(_userImageView.X, _userImageView.Y + _userImageView.Height + 15 * FIT_HEIGHT, self.Width - 40 * FIT_WIDTH, 1)];
    [self addSubview:_lineLabel];
    [_lineLabel release];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
